package com.myapp.struts;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

public class CategoriaActionForm
        extends org.apache.struts.action.ActionForm {

    private String idCategoria;
    private String categoria;

    public String getIdCategoria() {
        return idCategoria;
    }

    public void setIdCategoria(String idCategoria) {
        this.idCategoria = idCategoria;
    }

    public String getCategoria() {
        return categoria;
    }

    public void setCategoria(String categoria) {
        this.categoria = categoria;
    }

    public CategoriaActionForm() {
        super();
    }

    public ActionErrors validate(ActionMapping mapping,
            HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getCategoria() == null || 
                getCategoria().trim().length() < 1) {
            errors.add("categoria",
                    new ActionMessage("error.categoria.requerida"));
        }
        return errors;
    }
}


